package com.tensquare.friend.dao;

import com.tensquare.friend.pojo.Friend;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * Created by WF on 2020/12/23 16:02
 */
public interface FriendDao extends JpaRepository<Friend,String> {

    //1.根据当前用户id及好友id查询是否有记录
    @Query(nativeQuery=true,value="select count(*) from tb_friend where userid=?1 and friendid=?2")
    int selectCount(String id, String friendid);


    //2.更新islike的值
    @Modifying
    @Query(nativeQuery=true,value="update tb_friend set islike=?3 where userid=?1 and friendid=?2")
    void updateIsLike(String id, String friendid, String isLike);

    //3.从好友表删除记录
    @Modifying
    @Query(nativeQuery=true,value="delete from  tb_friend where userid=?1 and friendid=?2")
    void deleteUser(String userId, String friendid);
}
